<template>
  <div class="member-advance" :style="sectionStyle">
    <div class="advance-left">
      <div class="advance-img">
        <div class="item-hover">
          <div
            class="edit-box"
            @click.stop="handleClassifyTabItem('userMemberAdImgControl')"
          >
            <i class="iconfont icon-mokuai-bianji"></i>
          </div>
        </div>
        <img :src="memberAdImg" alt="" />
      </div>
      <p>{{ beforeBuyText || "开通Super会员，领7张20元无门槛津贴" }}</p>
    </div>
    <div class="advance-right">
      <p>去开通</p>
      <i class="iconfont icon-weibiaoti-13"></i>
    </div>
    <div class="box-hover">
      <div
        class="edit-box"
        @click.stop="handleClassifyTabItem('userMemberCardControl')"
      >
        <i class="iconfont icon-mokuai-bianji"></i>
      </div>
    </div>
    <div class="member-card-bg" :style="memberCardBg"></div>
  </div>
</template>

<script>
import defaultImg from "@/assets/images/diy/default_img.png";

export default {
  name: "userMember",
  props: {
    propsData: {
      type: Object,
      default: {},
    },
  },
  components: {},
  data() {
    return {};
  },
  mounted() {},
  watch: {},
  computed: {
    memberAdImg() {
      return this.propsData.params.memberAdImg || defaultImg;
    },
    showMemberCard() {
      return this.propsData.params.showModule;
    },
    beforeBuyText() {
      return this.propsData.params.beforeBuyText;
    },
    memberCardBg() {
      let style = Object.assign({}, this.propsData.params.memberCardCss);
      delete style.padding;
      delete style.borderRadius;
      return style;
    },
    sectionStyle() {
      let style = this.propsData.params.memberCardCss;
      let obj = {
        margin: `0 ${style.padding}px`,
        borderRadius: `${style.borderRadius}px ${style.borderRadius}px 0 0`,
      };
      return obj;
    },
  },
  methods: {
    // 点击编辑当前状态
    handleClassifyTabItem(name) {
      let data = Object.assign({}, this.propsData);
      data.controlComName = name;
      this.$emit("handleItemToControl", data);
    },
  },
};
</script>

<style lang="scss" scoped>
.member-advance {
  height: 38px;
  background: linear-gradient(270deg, #303478 0%, #303b93 100%);
  border-radius: 10px 10px 0px 0px;
  margin: 0 auto;
  display: flex;
  // align-items: center;
  justify-content: space-between;
  padding: 7px 12px 0;
  position: relative;
  z-index: 10;
  overflow: hidden;
  .advance-left {
    width: 75.83%;
    display: flex;
    // align-items: center;
    .advance-img {
      width: 30px;
      height: 18px;
      position: relative;
      z-index: 11;
      .item-hover {
        width: 100%;
        height: 100%;
        border: 1px solid #1890fc;
        position: absolute;
        left: 0;
        top: 0;
        display: none;
        .edit-box {
          width: 20px;
          height: 20px;
          background: #1890fc;
          border-radius: 0px 0px 0px 4px;
          display: flex;
          justify-content: center;
          align-items: center;
          cursor: pointer;
          position: absolute;
          right: 0;
          top: 0;
          .iconfont {
            font-size: 18px;
            color: #ffffff;
          }
        }
      }
      img {
        width: 100%;
        height: 100%;
        display: block;
      }
    }
    .advance-img:hover > .item-hover {
      display: block;
    }
    p {
      margin-bottom: 0;
      margin-left: 8px;
      font-size: 11px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #f8d070;
      max-width: 82%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
  .advance-right {
    display: flex;
    // align-items: center;
    justify-content: flex-end;
    p {
      margin-bottom: 0;
      margin-right: 6px;
      font-size: 11px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #f8d070;
    }
    .iconfont {
      transform: scale(0.95);
      font-size: 12px;
      color: #f8d070;
    }
  }
  .box-hover {
    width: 100%;
    height: 100%;
    border: 1px solid #1890fc;
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    .edit-box {
      width: 20px;
      height: 20px;
      background: #1890fc;
      border-radius: 0px 0px 0px 4px;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      position: absolute;
      right: 0;
      top: 0;
      .iconfont {
        font-size: 18px;
        color: #ffffff;
      }
    }
  }
  .member-card-bg {
    width: 100%;
    height: 100%;
    z-index: -1;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 10px 10px 0px 0px;
    background-color: #303478;
  }
}
.member-advance:hover > .box-hover {
  display: block;
}
</style>
